Instance Methods
The following instance methods are available globally.
-
Returns elements of this collection joined using a separator between each two elements. Last separator can be a different one.
Note
Useful to create strings like:
One, two, three and four
.Declaration
Swift
public func joined(separator: String, lastElementSeparator: String) -> String
Parameters
separator
Separator to be used between each two elements but the last pair.
lastElementSeparator
Separator to be used between last two elements.
Return Value
String with this collection’s elements joined.
-
Returns matches for given regex in this string.
Throws
NSError
if regex is malformed.Declaration
Swift
public func matches(for pattern: String) throws -> [String]
Parameters
pattern
Pattern to match in this string.
Return Value
Matches for given regex in this string.
-
Returns resulting string after removing occurrences of given substrings from this string.
Declaration
Swift
public func removing(_ targets: [String]) -> String
Parameters
targets
Substrings to be removed from this string.
Return Value
Resulting string.
-
Returns resulting string after removing occurrences of given substring from this string.
Declaration
Swift
public func removing(_ target: String) -> String
Parameters
target
Substring to be removed from this string.
Return Value
Resulting string.